home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
bipl.zip
/
PROCS.ZIP
/
MAPBIT.ICN
< prev
next >
Wrap
Text File
|
1992-09-28
|
2KB
|
54 lines
############################################################################
#
# File: mapbit.icn
#
# Subject: Procedures to map string into bit representation
#
# Author: Ralph E. Griswold
#
# Date: January 2, 1990
#
###########################################################################
#
# The procedure mapbit(s) produces a string of zeros and ones
# corresponding to the bit patterns for the characters of s. For
# example, mapbit("Axe") produces "010000010111100001100101".
#
############################################################################
#
# Links: collate
#
############################################################################
link collate
procedure bilit(text,alpha,first,second)
return collate(map(text,alpha,first),map(text,alpha,second))
end
procedure mapbit(s)
static all, base16, hex1, hex2, quad1, quad2, pair1, pair2
# The following is a bit ornate, but then ... . It could be
# made more compact (and cryptic) by using lists of templates
# and parameterizing the initialization.
initial {
all := string(&cset)
base16 := "0123456789ABCDEF"
hex1 := ""
every hex1 ||:= repl(!base16,16)
hex2 := repl(base16,16)
quad1 := ""
every quad1 ||:= repl(!left(base16,4),4)
quad2 := repl(left(base16,4),4)
pair1 := ""
every pair1 ||:= repl(!left(base16,2),2)
pair2 := repl(left(base16,2),2)
}
s := bilit(bilit(bilit(s,all,hex1,hex2),base16,quad1,quad2),left(base16,4),
pair1,pair2)
return s
end